﻿$(document).ready(function () {
    $('.firstnumber').bind('keypress', function (event) {
        if (event.keyCode != 8) {
            var regex = /^[1-9]+[0-9]*$/;
            var InputValue = String.fromCharCode(!event.keyCode ? event.which : event.keyCode);
            var key = $(this).val();
            key = key + InputValue;
            if (!regex.test(key)) {
                event.preventDefault();
                return false;
            }
        }
    });
});

//Textbox number decimal
//NumberDecimal = Number of Decimal  0 = none
//NotCheckDecimal = if Number of Decimal = 0, NotCheckDecimal = true
//UseDigit = if true 1,000 or if false 1000
//Symbol = ext. if textbox input 1000 and input $  result : $1000 or input "" result : 1000

function CurrencyTxtbox(Control, MinNum, MaxNum, UseComma) {
    jQuery(function ($) {
        if (UseComma == "1")
            $("#" + Control).autoNumeric('init', { vMin: MinNum, vMax: MaxNum });
        else
            $("#" + Control).autoNumeric('init', { vMin: MinNum, vMax: MaxNum, aSep: '' });
    });
}

function ProtectCopyPaseString(Control) {
    $("#" + Control).bind('cut copy paste', function (e) {
        var val = $(this).val();
        if (val != '0') {
            val = val.replace(/[^0-9]+/g, "");
            $(this).val(val);
        }
    });
}